<?php
namespace Open\Pages;
/**
 * Description of Page
 *
 * @author nofear
 */
class Catalog extends Page {
    
    public function index($key) {
        $this->view = new \System\Template('@open\catalog.twig');
        
        $Page       = $this->getCurrentPage($key);
        $categories = $this->EntityManager->getRepository('Shared\Main\Category')->findAll();
        $QB         = $this->EntityManager->createQueryBuilder();
        
        $products = $QB->select('p')
                ->from('Shared\Main\Product', 'p')
                ->orderBy('p.id', 'DESC')
                ->getQuery()->getResult();
        
        $this->view->Page       = $Page;
        $this->view->products   = $products;
        $this->view->categories = $categories;
    }
}
